home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 November / WNnov2005.iso / Windows / Equipement / hMailServer / hMailServer-4.1-Build-136.exe / {app} / DBScripts / CreateTablesMSSQL.sql next >
Encoding:
Text File  |  2005-07-18  |  18.3 KB  |  366 lines

  1. if exists (select * from sysobjects where id = object_id('hm_accounts') and objectproperty(id, 'isusertable') = 1) drop table hm_accounts ---
  2. if exists (select * from sysobjects where id = object_id('hm_imapfolders') and objectproperty(id, 'isusertable') = 1) drop table hm_imapfolders ---
  3. if exists (select * from sysobjects where id = object_id('hm_securityranges') and objectproperty(id, 'isusertable') = 1) drop table hm_securityranges ---
  4. if exists (select * from sysobjects where id = object_id('hm_aliases') and objectproperty(id, 'isusertable') = 1) drop table hm_aliases ---
  5. if exists (select * from sysobjects where id = object_id('hm_accounts') and objectproperty(id, 'isusertable') = 1) drop table hm_accounts ---
  6. if exists (select * from sysobjects where id = object_id('hm_domains') and objectproperty(id, 'isusertable') = 1) drop table hm_domains ---
  7. if exists (select * from sysobjects where id = object_id('hm_domain_aliases') and objectproperty(id, 'isusertable') = 1) drop table hm_domain_aliases ---
  8. if exists (select * from sysobjects where id = object_id('hm_messages') and objectproperty(id, 'isusertable') = 1) drop table hm_messages ---
  9. if exists (select * from sysobjects where id = object_id('hm_settings') and objectproperty(id, 'isusertable') = 1) drop table hm_settings ---
  10. if exists (select * from sysobjects where id = object_id('hm_dbversion') and objectproperty(id, 'isusertable') = 1) drop table hm_dbversion ---
  11. if exists (select * from sysobjects where id = object_id('hm_routes') and objectproperty(id, 'isusertable') = 1) drop table hm_routes ---
  12. if exists (select * from sysobjects where id = object_id('hm_routeaddresses') and objectproperty(id, 'isusertable') = 1) drop table hm_routeaddresses ---
  13. if exists (select * from sysobjects where id = object_id('hm_serverlog') and objectproperty(id, 'isusertable') = 1) drop table hm_serverlog ---
  14. if exists (select * from sysobjects where id = object_id('hm_distributionlists') and objectproperty(id, 'isusertable') = 1) drop table hm_distributionlists ---
  15. if exists (select * from sysobjects where id = object_id('hm_distributionlistsrecipients') and objectproperty(id, 'isusertable') = 1) drop table hm_distributionlistsrecipients ---
  16. if exists (select * from sysobjects where id = object_id('hm_messagerecipients') and objectproperty(id, 'isusertable') = 1) drop table hm_messagerecipients ---
  17. if exists (select * from sysobjects where id = object_id('hm_deliverylog') and objectproperty(id, 'isusertable') = 1) drop table hm_deliverylog ---
  18. if exists (select * from sysobjects where id = object_id('hm_deliverylog_recipients') and objectproperty(id, 'isusertable') = 1) drop table hm_deliverylog_recipients ---
  19. if exists (select * from sysobjects where id = object_id('hm_dnsbl') and objectproperty(id, 'isusertable') = 1) drop table hm_dnsbl ---
  20. if exists (select * from sysobjects where id = object_id('hm_fetchaccounts') and objectproperty(id, 'isusertable') = 1) drop table hm_fetchaccounts ---
  21. if exists (select * from sysobjects where id = object_id('hm_fetchaccounts_uids') and objectproperty(id, 'isusertable') = 1) drop table hm_fetchaccounts_uids ---
  22. if exists (select * from sysobjects where id = object_id('hm_rules') and objectproperty(id, 'isusertable') = 1) drop table hm_rules ---
  23. if exists (select * from sysobjects where id = object_id('hm_rule_criterias') and objectproperty(id, 'isusertable') = 1) drop table hm_rule_criterias ---
  24. if exists (select * from sysobjects where id = object_id('hm_rule_actions') and objectproperty(id, 'isusertable') = 1) drop table hm_rule_actions ---
  25. if exists (select * from sysobjects where id = object_id('hm_iphomes') and objectproperty(id, 'isusertable') = 1) drop table hm_iphomes ---
  26.  
  27. create table hm_accounts (
  28.     accountid int identity (1, 1) not null ,
  29.     accountdomainid int not null ,
  30.     accountadminlevel tinyint not null ,
  31.     accountaddress varchar (255) not null , CONSTRAINT u_accountaddress UNIQUE NONCLUSTERED (accountaddress),
  32.     accountpassword varchar (255) not null ,
  33.     accountactive int not null, 
  34.     accountisad int not null, 
  35.     accountaddomain varchar (255) not null ,
  36.     accountadusername varchar (255) not null,
  37.     accountmaxsize int not null default 0,
  38.     accountvacationmessageon tinyint not null default 0,
  39.     accountvacationmessage varchar (1000) not null default '',
  40.     accountvacationsubject varchar (200) not null default '',
  41.     accountpwencryption    tinyint not null 
  42. ) ---
  43.  
  44. CREATE CLUSTERED INDEX idx_hm_accounts ON hm_accounts (accountaddress) ---
  45.  
  46. create table hm_aliases (
  47.     aliasid int identity (1, 1) not null ,
  48.     aliasdomainid int not null ,
  49.     aliasname varchar (255) not null , CONSTRAINT u_aliasname UNIQUE NONCLUSTERED (aliasname),
  50.     aliasvalue varchar (255) not null ,
  51.     aliasactive tinyint not null,
  52.     aliastype tinyint not null
  53. ) ---
  54.  
  55. CREATE CLUSTERED INDEX idx_hm_aliases ON hm_aliases (aliasdomainid, aliasname) ---
  56.  
  57. create table hm_domains (
  58.     domainid int identity (1, 1) not null ,
  59.     domainname varchar (80) not null, CONSTRAINT u_domainname UNIQUE NONCLUSTERED (domainname),
  60.     domainactive tinyint not null,
  61.     domainpostmaster varchar (80) not null,
  62.     domainmaxsize int not null,
  63.     domainaddomain varchar(255) not null,
  64.     domainmaxmessagesize int not null
  65. ) ---
  66.  
  67. CREATE CLUSTERED INDEX idx_hm_domains ON hm_domains (domainname) ---
  68.  
  69. create table hm_domain_aliases (
  70.     daid int identity (1, 1) not null ,
  71.     dadomainid integer not null ,
  72.     daalias varchar(255) not null
  73. ) ---
  74.  
  75. create table hm_messages (
  76.     messageid bigint identity (1, 1) not null ,
  77.     messageaccountid int not null ,
  78.     messagefolderid int not null ,
  79.     messagefilename varchar (255) not null ,
  80.     messagetype tinyint not null ,
  81.     messagefrom varchar (100) not null ,
  82.     messagerecipients varchar (500) not null ,
  83.     messagesize int not null,
  84.     messagecurnooftries int not null DEFAULT 0,
  85.     messagenexttrytime datetime not null DEFAULT GETDATE(),
  86.     messageflagseen tinyint not null,
  87.     messageflagdeleted tinyint not null,
  88.     messageflagrecent tinyint not null,
  89.     messageflaganswered tinyint not null,
  90.     messageflagflagged tinyint not null,
  91.     messageflagdraft tinyint not null,    
  92.     messagerecipientsparsed tinyint not null,
  93.     messagecreatetime datetime not null DEFAULT GETDATE(),
  94.     messagelocked tinyint not null
  95. ) ---
  96.  
  97. CREATE CLUSTERED INDEX idx_hm_messages ON hm_messages (messageaccountid, messagefolderid) ---
  98.  
  99. create table hm_settings (
  100.     settingid int identity (1, 1) not null ,
  101.     settingname varchar (30) not null , CONSTRAINT u_settingname UNIQUE NONCLUSTERED (settingname),
  102.     settingstring varchar (255) not null ,
  103.     settinginteger int not null
  104. ) ---
  105.  
  106. create table hm_dbversion (
  107.     value int not null
  108. ) ---
  109.  
  110. create table hm_serverlog (
  111.     logid int identity (1, 1) not null ,
  112.     logprocessid int not null,
  113.     logthreadid int not null,    
  114.     logsource int not null,
  115.     logtime datetime not null,
  116.     logremotehost varchar(15) not null,
  117.     logtext varchar(600)
  118. ) ---
  119.  
  120. create table hm_distributionlists 
  121. (
  122.     distributionlistid int identity (1, 1) not null,
  123.     distributionlistdomainid int not null,
  124.     distributionlistaddress varchar(255) not null, CONSTRAINT u_distributionlistaddress UNIQUE NONCLUSTERED (distributionlistaddress),
  125.     distributionlistenabled tinyint not null,    
  126.    distributionlistrequireauth tinyint not null,
  127.     distributionlistrequireaddress varchar(255) not null
  128. ) ---
  129.  
  130. CREATE CLUSTERED INDEX idx_hm_distributionlists_distributionlistdomainid ON hm_distributionlists (distributionlistdomainid) ---
  131.  
  132. create table hm_distributionlistsrecipients
  133. (
  134.     distributionlistrecipientid int identity (1, 1) not null,
  135.     distributionlistrecipientlistid int not null,
  136.     distributionlistrecipientaddress varchar(255)    
  137. ) ---
  138.  
  139. CREATE CLUSTERED INDEX idx_hm_distributionlistsrecipients_distributionlistrecipientlistid ON hm_distributionlistsrecipients (distributionlistrecipientlistid) ---
  140.  
  141. create table hm_messagerecipients
  142. (
  143.     recipientid bigint identity (1, 1) not null,
  144.    recipientmessageid bigint not null,
  145.     recipientaddress varchar(255) not null,
  146.     recipientislocal tinyint not null,
  147.     recipientisenabled tinyint not null,
  148.     recipientisexisting tinyint not null,
  149.     recipientlocalaccountid int not null
  150. ) ---
  151.  
  152. CREATE CLUSTERED INDEX idx_hm_messagerecipients_recipientmessageid ON hm_messagerecipients (recipientmessageid) ---
  153.  
  154. create table hm_imapfolders 
  155. (
  156.     folderid int identity (1, 1) not null,
  157.     folderaccountid int NOT NULL,
  158.     folderparentid int NOT NULL,
  159.     foldername varchar(255) NOT NULL,
  160.     folderissubscribed tinyint NOT NULL
  161. ) ---
  162.  
  163. CREATE CLUSTERED INDEX idx_hm_imapfolders_folderaccountid ON hm_imapfolders (folderaccountid) ---
  164.  
  165. create table hm_securityranges
  166. (
  167.     rangeid int identity (1, 1) not null,
  168.       rangepriorityid int not null,
  169.     rangelowerip bigint not null,
  170.     rangeupperip bigint not null,
  171.     rangeoptions int not null,
  172.     rangename varchar (100) not null, CONSTRAINT u_rangename UNIQUE NONCLUSTERED (rangename)
  173. ) ---
  174.  
  175. insert into hm_securityranges (rangepriorityid, rangelowerip, rangeupperip, rangeoptions, rangename) values (10, 0, 4294967295, 491, 'Internet') ---
  176. insert into hm_securityranges (rangepriorityid, rangelowerip, rangeupperip, rangeoptions, rangename) values (15, 2130706433, 2130706433, 459, 'My computer') ---
  177.  
  178. create table hm_routes 
  179. (
  180.   routeid int identity (1, 1) not null,
  181.   routedomainname varchar(255) NOT NULL, CONSTRAINT u_routedomainname UNIQUE NONCLUSTERED (routedomainname),
  182.   routetargetsmthost varchar(255) NOT NULL,
  183.   routetargetsmtport int NOT NULL,
  184.   routenooftries int NOT NULL,
  185.   routeminutesbetweentry int NOT NULL,
  186.   routealladdresses tinyint NOT NULL,
  187.   routeuseauthentication tinyint NOT NULL,
  188.   routeauthenticationusername varchar(255) NOT NULL,
  189.   routeauthenticationpassword varchar(255) NOT NULL,
  190.   routetreatsecurityaslocal tinyint NOT NULL 
  191. ) ---
  192.  
  193. create table hm_routeaddresses
  194. (
  195.   routeaddressid int identity (1, 1) not null,
  196.   routeaddressrouteid int NOT NULL,
  197.   routeaddressaddress varchar(255) NOT NULL
  198. ) ---
  199.  
  200. create table hm_deliverylog
  201. (
  202.     deliveryid int identity (1, 1) not null,
  203.     deliveryfrom varchar(255) not null,
  204.    deliveryfilename varchar(255) not null,
  205.    deliverytime datetime not null,
  206.     deliverysubject varchar(255) not null,
  207.     deliverybody varchar(7000) not null
  208. ) ---
  209.  
  210. create table hm_deliverylog_recipients
  211. (
  212.     deliveryrecipientid int identity (1, 1) not null,
  213.    deliveryid int not null,
  214.     deliveryrecipientaddress varchar(255) not null
  215. ) ---
  216.  
  217. create table hm_dnsbl
  218. (
  219.     sblid int identity (1, 1) not null,
  220.    sblactive int not null,
  221.    sbldnshost varchar(255) not null,
  222.    sblresult varchar(255) not null,
  223.    sblrejectmessage varchar(255) not null
  224. ) ---
  225.  
  226. create table hm_fetchaccounts
  227. (    
  228.     faid int identity(1,1) not null,
  229.     faactive tinyint not null,
  230.     faaccountid int not null,
  231.     faaccountname varchar (255) not null,
  232.     faserveraddress varchar (255) not null,
  233.     faserverport int not null,
  234.     faservertype tinyint not null,
  235.     fausername varchar (255) not null,
  236.     fapassword varchar (255) not null,
  237.     faminutes int not null,
  238.     fanexttry datetime not null,
  239.     fadaystokeep int not null,
  240.     falocked tinyint not null
  241. ) ---
  242.  
  243. create table hm_fetchaccounts_uids
  244. (
  245.     uidid int identity(1,1) not null,
  246.     uidfaid int not null,
  247.     uidvalue varchar(255) not null,
  248.     uidtime datetime not null
  249. ) ---
  250.  
  251. CREATE CLUSTERED INDEX idx_hm_fetchaccounts_uids ON hm_fetchaccounts_uids (uidfaid) ---
  252.  
  253. create table hm_rules
  254. (
  255.     ruleid int identity(1,1) not null,
  256.     ruleaccountid int not null,
  257.     rulename varchar(100) not null,
  258.     ruleactive tinyint not null,
  259.     ruleuseand tinyint not null,
  260.     rulesortorder int not null
  261. ) ---
  262.  
  263. CREATE CLUSTERED INDEX idx_hm_rules ON hm_rules (ruleaccountid) ---
  264.  
  265. create table hm_rule_criterias
  266. (
  267.     criteriaid int identity(1,1) not null,
  268.     criteriaruleid int not null,
  269.     criteriausepredefined tinyint not null,
  270.     criteriapredefinedfield tinyint not null,
  271.     criteriaheadername varchar(255) not null,
  272.     criteriamatchtype tinyint not null,
  273.     criteriamatchvalue varchar(255) not null
  274.     
  275. ) ---
  276.  
  277. CREATE CLUSTERED INDEX idx_hm_rule_criterias ON hm_rule_criterias (criteriaruleid) ---
  278.  
  279. create table hm_rule_actions
  280. (
  281.     actionid int identity(1,1) not null,
  282.     actionruleid int not null,
  283.     actiontype tinyint not null,
  284.     actionimapfolder varchar(255) not null,
  285.     actionsubject varchar(255) not null,
  286.     actionfromname varchar(255) not null,
  287.     actionfromaddress varchar(255) not null,
  288.     actionto varchar(255) not null,
  289.     actionbody varchar(5000) not null,
  290.     actionfilename varchar(255) not null,
  291.     actionsortorder int not null
  292. ) ---
  293.  
  294. CREATE CLUSTERED INDEX idx_hm_rule_actions ON hm_rule_actions (actionruleid) ---
  295.  
  296. create table hm_adsynchronization
  297. (
  298.     synchid int identity(1,1) not null,
  299.     synchaccountid int not null,
  300.     synchguid varchar(50) not null
  301. ) ---
  302.  
  303. create table hm_iphomes
  304. (
  305.     iphomeid int identity(1,1) not null,
  306.     iphomeaddress bigint  not null
  307. ) ---
  308.  
  309. insert into hm_dnsbl (sblactive, sbldnshost, sblresult, sblrejectmessage) values (0, 'sbl-xbl.spamhaus.org', '127.0.0.*', 'Rejected by Spamhaus') ---
  310. insert into hm_dnsbl (sblactive, sbldnshost, sblresult, sblrejectmessage) values (0, 'relays.ordb.org', '127.0.0.*', 'Rejected by ORDB') ---
  311. insert into hm_dnsbl (sblactive, sbldnshost, sblresult, sblrejectmessage) values (0, 'bl.spamcop.net', '127.0.0.*', 'Rejected by SpamCop') ---
  312.  
  313.  
  314. insert into hm_settings (settingname, settingstring, settinginteger) values ('smtpport', '', 25) ---
  315. insert into hm_settings (settingname, settingstring, settinginteger) values ('pop3port', '', 110) ---
  316. insert into hm_settings (settingname, settingstring, settinginteger) values ('maxpop3connections', '', 0) ---
  317. insert into hm_settings (settingname, settingstring, settinginteger) values ('maxsmtpconnections', '', 0) ---
  318. insert into hm_settings (settingname, settingstring, settinginteger) values ('mirroremailaddress', '', 0) ---
  319. insert into hm_settings (settingname, settingstring, settinginteger) values ('relaymode', '', 2) ---
  320. insert into hm_settings (settingname, settingstring, settinginteger) values ('authallowplaintext', '', 0) ---
  321. insert into hm_settings (settingname, settingstring, settinginteger) values ('allowmailfromnull', '', 1) ---
  322. insert into hm_settings (settingname, settingstring, settinginteger) values ('logging', '', 0) ---
  323. insert into hm_settings (settingname, settingstring, settinginteger) values ('logdevice', '', 0) ---
  324. insert into hm_settings (settingname, settingstring, settinginteger) values ('tarpitdelay', '', 0) ---
  325. insert into hm_settings (settingname, settingstring, settinginteger) values ('tarpitcount', '', 0) ---
  326. insert into hm_settings (settingname, settingstring, settinginteger) values ('smtpnoofretries', '', 4) ---
  327. insert into hm_settings (settingname, settingstring, settinginteger) values ('smtpminutesbetweenretries', '', 60) ---
  328. insert into hm_settings (settingname, settingstring, settinginteger) values ('smtpnooftries', '', 0) ---
  329. insert into hm_settings (settingname, settingstring, settinginteger) values ('protocolimap', '', 1) ---
  330. insert into hm_settings (settingname, settingstring, settinginteger) values ('protocolsmtp', '', 1) ---
  331. insert into hm_settings (settingname, settingstring, settinginteger) values ('protocolpop3', '', 1) ---
  332. insert into hm_settings (settingname, settingstring, settinginteger) values ('welcomeimap', '', 0) ---
  333. insert into hm_settings (settingname, settingstring, settinginteger) values ('welcomepop3', '', 0) ---
  334. insert into hm_settings (settingname, settingstring, settinginteger) values ('welcomesmtp', '', 0) ---
  335. insert into hm_settings (settingname, settingstring, settinginteger) values ('smtprelayer', '', 0) ---
  336. insert into hm_settings (settingname, settingstring, settinginteger) values ('imapport', '', 143) ---
  337. insert into hm_settings (settingname, settingstring, settinginteger) values ('maxdelivertythreads', '', 3) ---
  338. insert into hm_settings (settingname, settingstring, settinginteger) values ('logformat', '', 0) ---
  339. insert into hm_settings (settingname, settingstring, settinginteger) values ('avclamwinenable', '', 0) ---
  340. insert into hm_settings (settingname, settingstring, settinginteger) values ('avclamwinexec', '', 0) ---
  341. insert into hm_settings (settingname, settingstring, settinginteger) values ('avclamwindb', '', 0) ---
  342. insert into hm_settings (settingname, settingstring, settinginteger) values ('avnotifysender', '', 0) ---
  343. insert into hm_settings (settingname, settingstring, settinginteger) values ('avnotifyreceiver', '', 0) ---
  344. insert into hm_settings (settingname, settingstring, settinginteger) values ('avaction', '', 0) ---
  345. insert into hm_settings (settingname, settingstring, settinginteger) values ('sendstatistics', '', 0) ---
  346. insert into hm_settings (settingname, settingstring, settinginteger) values ('hostname', '', 0) ---
  347. insert into hm_settings (settingname, settingstring, settinginteger) values ('smtprelayerusername', '', 0) ---
  348. insert into hm_settings (settingname, settingstring, settinginteger) values ('smtprelayerpassword', '', 0) ---
  349. insert into hm_settings (settingname, settingstring, settinginteger) values ('usesmtprelayerauthentication', '', 0) ---
  350. insert into hm_settings (settingname, settingstring, settinginteger) values ('smtprelayerport', '', 25) ---
  351. insert into hm_settings (settingname, settingstring, settinginteger) values ('usedeliverylog', '', 0) ---
  352. insert into hm_settings (settingname, settingstring, settinginteger) values ('usecustomvirusscanner', '', 0) ---
  353. insert into hm_settings (settingname, settingstring, settinginteger) values ('customvirusscannerexecutable', '', 0) ---
  354. insert into hm_settings (settingname, settingstring, settinginteger) values ('customviursscannerreturnvalue', '', 0) ---
  355. insert into hm_settings (settingname, settingstring, settinginteger) values ('usespf', '', 0) ---
  356. insert into hm_settings (settingname, settingstring, settinginteger) values ('usemxchecks', '', 0) ---
  357. insert into hm_settings (settingname, settingstring, settinginteger) values ('usescriptserver', '', 0) ---
  358. insert into hm_settings (settingname, settingstring, settinginteger) values ('scriptlanguage', 'VBScript', 0) ---
  359. insert into hm_settings (settingname, settingstring, settinginteger) values ('maxmessagesize', '', 0)  ---
  360. insert into hm_settings (settingname, settingstring, settinginteger) values ('listenonalladdresses', '', 1)  ---
  361. insert into hm_settings (settingname, settingstring, settinginteger) values ('usecache', '', 0) ---
  362. insert into hm_settings (settingname, settingstring, settinginteger) values ('domaincachettl', '', 60)  ---
  363.  
  364. insert into hm_dbversion values (4100) ---
  365.  
  366.